package com.tech.jvm;

import jdk.nashorn.internal.objects.annotations.Where;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @Author: zl
 * @Date: 2019/7/4 17:55
 */
public class HeapMemoryOptimization {

    public static void main(String[] args) {


        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("a");
        list.add("a");
        System.out.println(list.toString());

        long maxMemory = Runtime.getRuntime().maxMemory() ;//返回 Java 虚拟机试图使用的最大内存量。
        long totalMemory = Runtime.getRuntime().totalMemory() ;//返回 Java 虚拟机中的内存总量。
        System.out.println("MAX_MEMORY = " + maxMemory + "（字节）、" + (maxMemory / (double)1024 / 1024) + "MB");
        System.out.println("TOTAL_MEMORY = " + totalMemory + "（字节）、" + (totalMemory / (double)1024 / 1024) + "MB");
        while (true) {
            String[] strings = new String[1000000];
        }
    }
}


